package com.jy.adscm.operation.hscrb.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.operation.hscrb.bean.QxCleandetail;
import com.jy.adscm.operation.hscrb.mapper.mysql.QxCleandetailMapper;
import com.jy.adscm.operation.hscrb.service.QxCleandetailService;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2018-12-17
 */
@Service
public class QxCleandetailServiceImpl extends ServiceImpl<QxCleandetailMapper, QxCleandetail> implements QxCleandetailService {
   @Autowired
    JyUserMapper jyUserMapper ;
    @Override
    public Boolean updateQxCleandetail(QxCleandetail qxCleandetail) {
        boolean result = super.updateById(qxCleandetail);
        return result;
    }

    @Override
    public List<QxCleandetail> selectByTid(String tid) {
        Wrapper<QxCleandetail> wrapper =new EntityWrapper<>();
        wrapper.eq("TID",tid);
        List<QxCleandetail> qxCleandetails = super.selectList(wrapper);
        for (QxCleandetail qxCleandetail : qxCleandetails) {
            if (AdscmBaseUtils.getInstance().isNotEmpty(qxCleandetail.getType(),null)){
                JyUser jyUser = jyUserMapper.selectById(qxCleandetail.getType());
                qxCleandetail.setTypeName(jyUser.getName());
            }

        }
        return qxCleandetails;
    }

    @Override
    public List<JyUser> selectUser() {
        Wrapper<JyUser> wrapper=new EntityWrapper<>();
        wrapper.setSqlSelect("id","name");

        List<JyUser> jyUsers = jyUserMapper.selectList(wrapper);
        return jyUsers;
    }
}
